package main

import "fmt"

//使用值接收者实现接口和使用指针接收者实现接口

type mover interface {
	move()
}

type person struct {
	name string
	age  int8
}

//值接收者实现接口：类型的值和类型的指针都能保存到接口变量中
//func (p person) move() {
//	fmt.Printf("%s在跑...\n", p.name)
//}

//指针接收者实现接口：只有类型指针能保存到接口变量中
func (p *person) move() {
	fmt.Printf("%s在跑...\n", p.name)
}
func main() {
	//var m mover
	//
	//p1 := person{
	//	name: "chen",
	//	age:  18,
	//}
	//m = &p1 //todo?
	//m.move()
	//
	//p2 := &person{
	//	name: "hello",
	//	age:  20,
	//}
	//m = p2
	//m.move()
	//
	//var m1 = make(map[string]interface{},16)
	//m1["name"] = "chen"
	//m1["age"] = 18
	//m1["hobby"] = []string{
	//	"篮球",
	//	"足球",
	//}
	//fmt.Println(m1)

	var x interface{}

	x = "ss"
	x = 11
	x = false

	switch v := x.(type) {
	case string:
		fmt.Printf("是字符串，value：%v\n", v)
	case bool:
		fmt.Printf("是bool，value：%v\n", v)
	case int:
		fmt.Printf("是字符串，value：%v\n", v)
	}
}
